package com.utc.teamcenter.common.app.dialog.bean;

import javax.swing.JComponent;

import com.teamcenter.rac.util.iTextField;
import com.utc.teamcenter.common.util.TCUtil;

public class BeanITextField extends BeanComponent {

	private iTextField field;

	public BeanITextField(String key, String name, String value,
			boolean required) {
		this(key, name, value, required, DEFAULT_LENGTH, TCUtil
				.getDefaultMaxNameSize());
	}

	public BeanITextField(String key, String name, String value,
			boolean required, int length, int limit) {
		super(key, name);

		this.field = new iTextField(TCUtil.createFilterDocument(), value,
				length, limit, required, null);
		this.field.setName(key);
	}

	@Override
	public void clear() {
		this.field.setText("");
	}

	@Override
	public JComponent getComponent() {
		return this.field;
	}

	@Override
	public String getText() {
		return this.field.getText();
	}

	@Override
	public boolean isRequired() {
		return this.field.isRequired();
	}

	@Override
	public void setText(String text) {
		this.field.setText(text);
	}

	@Override
	public void setRequired(boolean required) {
		this.field.setRequired(required);
	}

	@Override
	public void requestFocus() {
		this.field.requestFocus();
	}

	@Override
	public void setEnabled(boolean bool) {
		this.field.setEnabled(bool);
	}

	@Override
	public void setVisible(boolean bool) {
		this.field.setVisible(bool);
	}
}
